<template>
  <iframe ref="iframe" v-if="chartId" :src="iframeSrc" id="my-iframe" class="report" frameborder="0"></iframe>
</template>
<script lang="ts" setup>
  import { ref, watchEffect, nextTick } from 'vue';
  import { getToken } from '/@/utils/auth';
  import qs from 'qs';
  const baseUrl = import.meta.env.VITE_GLOB_DOMAIN_URL;
  // const baseUrl = 'http://192.168.61.196:3100/jeecg-boot';
  const props = defineProps({
    chartId: {
      type: String,
      required: true,
    },
    params: {
      type: Object,
      default: () => ({}),
    },
  });

  const iframeSrc = ref('');
  const token = getToken();

  const iframe = ref<HTMLIFrameElement>();
  watchEffect(() => {
    const queryString = qs.stringify({ ...props.params, token });
    iframeSrc.value = `${baseUrl}/jmreport/view/${props.chartId}?${queryString}`;
    nextTick(() => {
      // iframe.value?.contentWindow?.location.reload();
    });
  });
</script>
<style scoped>
  .report {
    width: 100%;
    height: 100%;
    padding-bottom: 20px;
  }
  .report body .jm-sheet-wrapper .jm-sheet-scrollbar.horizontal {
    height: 4px;
  }
</style>
<style></style>
